package flc.ast.adapter;


import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.FortuneBean;
import flc.ast.bean.StarsBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class FortuneAdapter extends StkProviderMultiAdapter<FortuneBean> {

    public FortuneAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new FortuneProvider());
    }

    private class FortuneProvider extends BaseItemProvider<FortuneBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_fortune;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, FortuneBean bean) {
            baseViewHolder.setText(R.id.tvFortuneItemName, bean.getName());
            if (bean.isSelected()) {
                baseViewHolder.getView(R.id.ivFortuneItemSel).setVisibility(View.VISIBLE);
                baseViewHolder.setBackgroundColor(R.id.llFortuneItem, Color.parseColor("#E5B222"));
                baseViewHolder.setTextColor(R.id.tvFortuneItemName, Color.parseColor("#FFFFFF"));
                TextView textView = baseViewHolder.getView(R.id.tvFortuneItemName);
                textView.setTextSize(20);
            } else {
                baseViewHolder.getView(R.id.ivFortuneItemSel).setVisibility(View.GONE);
                baseViewHolder.setBackgroundColor(R.id.llFortuneItem, Color.parseColor("#EFCE6E"));
                baseViewHolder.setTextColor(R.id.tvFortuneItemName, Color.parseColor("#BAFFFFFF"));
                TextView textView = baseViewHolder.getView(R.id.tvFortuneItemName);
                textView.setTextSize(18);
            }
        }
    }

}
